package com.yunji.system.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.constant.LogicCode;
import com.yunji.common.model.domain.NoticeImeiDO;
import com.yunji.system.dao.INoticeImeiDao;
import com.yunji.system.mapper.INoticeImeiMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class NoticeImeiDaoImpl extends BaseDaoImpl<INoticeImeiMapper, NoticeImeiDO> implements INoticeImeiDao {
    @Override
    public List<NoticeImeiDO> selectNoConsume() {
        return list(new LambdaQueryWrapper<NoticeImeiDO>()
                .eq(NoticeImeiDO::getIsConsume, LogicCode.NO));
    }

    @Override
    public void consumeNotice() {
        update(new LambdaUpdateWrapper<NoticeImeiDO>()
                .set(NoticeImeiDO::getIsConsume, LogicCode.YES)
                .eq(NoticeImeiDO::getIsConsume, LogicCode.NO));
    }
}
